package leetcode.bitarithmetic;

public class NumberComplement476 {
    class Solution {
        public int findComplement(int num) {
            int ans = 0;
            int i = 0;
            while (num != 0) {
                ans |= ((num & 1 ^ 1) << i);
                i++;
                num >>= 1;
            }
            return ans;
        }
    }
}
